package huhx.linux.com.kotlinlearn.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import huhx.linux.com.kotlinlearn.R;
import huhx.linux.com.kotlinlearn.model.UserEvent;

/**
 * Created by huhx on 2018-03-20 下午 8:56.
 */

public class SecondActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);

        EventBus.getDefault().register(SecondActivity.this);
    }


    @Subscribe(threadMode = ThreadMode.POSTING, sticky = true)
    public void onMoonEvent(UserEvent userevent) {
        Toast.makeText(this, "user = " + userevent, Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(SecondActivity.this);
    }
}
